package bavaria.hightec.banking;

import java.util.ResourceBundle;


public class ConvertMoney {
	//CHF,USD,GBP,RUB
	private static ResourceBundle cur;
	
	public static Money convert(long betrag,Currency waehrung){
		cur = BankImpl.getLocale();
		double[] exchangeRateList = {Double.valueOf(cur.getString("exCHF")),Double.valueOf(cur.getString("USD/EUR")),
										Double.valueOf(cur.getString("exGBP")),Double.valueOf(cur.getString("exRUB"))};
		
		String value = cur.getString("USD");
		if(waehrung== Currency.CHF){
			betrag=(long) (betrag*exchangeRateList[0]);
		}
		else if(waehrung== Currency.valueOf(value)){
			betrag=(long) (betrag*exchangeRateList[1]);
		}
		else if(waehrung== Currency.GBP){
			betrag=(long) (betrag*exchangeRateList[2]);
		}
		else if(waehrung== Currency.RUB){
			betrag=(long) (betrag*exchangeRateList[3]);
		}
		
		value = cur.getString("EUR");
		waehrung=Currency.valueOf(value);
		
		return new Money(betrag,Account.getCurrency());
		
	}
}
